#include <stdio.h>
#define X 100

int max_number_in_three(int x,int y,int z)
{
	if(x >= y && x >= z)
		return x;
	if(y >= x && y >= z)
		return y;
	return z;
}

int max_array(int *arr,int l,int r)
{
	if(r - l == 0)
		return arr[l];
	if(r - l == 1)
		return max_number_in_three(arr[l],arr[r],arr[l] + arr[r]);
	int mid = (r + l) / 2;
	int l_max = max_array(arr,l,mid);
	int r_max = max_array(arr,mid + 1,r);
	int max_l = arr[mid];
	int max_r = arr[mid + 1];
	int max_now = 0;
	for(int i = mid;i >= 0;i--)
	{
		max_now += arr[i];
		if(max_now > max_l)
			max_l = max_now;
	}
	max_now = 0;
	for(int i = mid + 1;i <= r;i++)
	{
		max_now += arr[i];
		if(max_now > max_r)
			max_r = max_now;
	}
	return max_number_in_three(l_max,r_max,max_l + max_r);
}

int main()
{
	int i,arr[X];
	for(i = 0;i < X;i++)
	{
		scanf("%d",&arr[i]);
	}
	printf("%d\n",max_array(arr,0,X-1));
	return 0;
}
